package wildlife;
import java.io.*;
import java.sql.*;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
public class uploadresume {
File resume;int jobid;
public File getResume() {
	return resume;
}
public void setResume(File resume) {
	this.resume = resume;
}
public int getJobid() {
	return jobid;
}
public void setJobid(int jobid) {
	this.jobid = jobid;
}
public String execute() throws Exception{

	File f=new File("C:/Users/SIVA KRISHNA/workspace/wildlife/WebContent/resumes/"+jobid);
	if(!f.exists()){
		f.mkdir();
	}
	String username=ServletActionContext.getRequest().getSession().getAttribute("username").toString();
	File f1=new File("C:/Users/SIVA KRISHNA/workspace/wildlife/WebContent/resumes/"+jobid+"/"+username+".pdf");
	FileUtils.copyFile(resume,f1);
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/wildlife","root","");
	PreparedStatement ps=con.prepareStatement("insert into jobappliers values(?,?)");
	//String username=ServletActionContext.getRequest().getSession().getAttribute("username").toString();
	ps.setInt(1,jobid);
	
	ps.setString(2,username);
	ps.executeUpdate();
	return "success";

}

}
